Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the @Cacheable key generation logic in StoreService.java to handle null values for category and district enums using safe navigation and default values. The reviewer suggested extending the cache condition to also cover blank or empty name strings (#name.isBlank()) to improve cache efficiency.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| * Specification 사용으로 PostgreSQL+enum 조합에서 :param IS NULL 회피. | ||
| */ | ||
| @Cacheable(value = "storeList", key = "T(String).valueOf(#category) + ':' + T(String).valueOf(#district) + ':' + #page + ':' + #size", condition = "#name == null") | ||
| @Cacheable(value = "storeList", key = "(#category?.name() ?: 'ALL') + ':' + (#district?.name() ?: 'ALL') + ':' + #page + ':' + #size", condition = "#name == null") |
There was a problem hiding this comment.
현재 getStores 메서드 내부에서는 name 파라미터가 null이거나 공백(isBlank())일 때 trimmedName을 null로 처리하여 이름 필터링 없이 조회를 수행합니다.
하지만 @Cacheable의 condition은 #name == null로만 설정되어 있어, name이 빈 문자열("")이거나 공백으로만 이루어진 문자열(" ")일 경우 실제 쿼리는 이름 필터링 없이 동일하게 수행됨에도 불구하고 캐시를 타지 않고 매번 DB를 조회하게 됩니다.
캐시 효율성을 높이기 위해 condition 조건을 #name == null || #name.isBlank()로 수정하여 공백 문자열 입력 시에도 캐시가 적용되도록 개선하는 것을 추천합니다. SpEL의 || 연산자는 단락 평가(short-circuit evaluation)를 지원하므로 #name이 null일 때 뒤의 isBlank()가 호출되지 않아 안전합니다.
| @Cacheable(value = "storeList", key = "(#category?.name() ?: 'ALL') + ':' + (#district?.name() ?: 'ALL') + ':' + #page + ':' + #size", condition = "#name == null") | |
| @Cacheable(value = "storeList", key = "(#category?.name() ?: 'ALL') + ':' + (#district?.name() ?: 'ALL') + ':' + #page + ':' + #size", condition = "#name == null || #name.isBlank()") |
📢 기능 설명
필요시 실행결과 스크린샷 첨부
연결된 issue
연결된 issue를 자동을 닫기 위해 아래 {이슈넘버}를 입력해주세요.
close #{이슈넘버}
✅ 체크리스트